{literal}
	<style type="text/css" media="screen">
 			.chat_time {
 				font-style: italic;
 				font-size: 9px;
 			}
 		</style>
{/literal}
	<script language="JavaScript" type="text/javascript">
 			var sendReq = getXmlHttpRequestObject();
 			var receiveReq = getXmlHttpRequestObject();
 			var lastMessage = 0;
 			var iChat = {$iChatId};
 			var bProc = true;
 			var mTimer;
 			var sHome = "{$sBaseUrl}";
{literal}
 			function startChat()
 			{
 				getChatText();
 				document.getElementById('maintext').focus();
 			}

 			function getXmlHttpRequestObject()
 			{
 				if (window.XMLHttpRequest)
 				{
 					return new XMLHttpRequest();
 				}
 				else if(window.ActiveXObject)
 				{
 					return new ActiveXObject("Microsoft.XMLHTTP");
 				}
 				else
 				{
 					document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
 				}
 			}

 			function getChatText()
 			{
 				if (receiveReq.readyState == 4 || receiveReq.readyState == 0)
 				{
 				    if (bIsPathTranslated)
 				    {
 				       var sReqUrl = sHome + 'index.php/' + 'public/im/proc_true/chat_'+iChat+'/last_' + lastMessage;
 				    } else
 				    {
 				        var sReqUrl = sHome + 'index.php?' + sGetPathVar + '=' + '/public/im/proc_true/chat_'+iChat+'/last_' + lastMessage;
 				    }
 					receiveReq.open("GET", sReqUrl, true);
 					receiveReq.onreadystatechange = handleReceiveChat;
 					receiveReq.send(null);
 				}
 			}

 			function sendChatText()
 			{
 			    var sTxt = document.getElementById('maintext').value;
 			    sTxt = sTxt.replace(/^\n+|\r\n+$/m, ' ');

 			    if(sTxt == '')
 				{
 					alert("You have not entered a message");
 					document.getElementById('maintext').value = '';
 					document.getElementById('maintext').focus();
 					return;
 				}
 				if (sendReq.readyState == 4 || sendReq.readyState == 0)
 				{
 				    if (bIsPathTranslated)
 				    {
 				       var sReqUrl = sHome + 'index.php/' + 'public/im/proc_true/chat_'+iChat+'/last_'+lastMessage;
 				    } else
 				    {
 				        var sReqUrl = sHome + 'index.php?' + sGetPathVar + '=' + '/public/im/proc_true/chat_'+iChat+'/last_'+lastMessage;
 				    }
 					sendReq.open("POST", sReqUrl, true);
 					sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 					sendReq.onreadystatechange = handleSendChat;
 					var param;
 					param = 'message='+sTxt;
 					sendReq.send(param);

 					document.getElementById('maintext').value = '';
 				    document.getElementById('maintext').focus();
 				}
 			}

 			function handleSendChat()
 			{
 				clearTimeout(mTimer);
 				getChatText();
 			}

 			function handleReceiveChat()
 			{
 				if (bProc && receiveReq.readyState == 4 || receiveReq.readyState == 0)
 				{
 					var chat_div = document.getElementById('div_chat');
 					var xmldoc = receiveReq.responseXML;
 					var message_nodes = xmldoc.getElementsByTagName("message");
 					var n_messages = message_nodes.length;

 					if(n_messages)
 					{
     					for (i = 0; i < n_messages; i++)
     					{
     						var user_node = message_nodes[i].getElementsByTagName("user");
     						var text_node = message_nodes[i].getElementsByTagName("text");
     						var time_node = message_nodes[i].getElementsByTagName("time");
     						if(message_nodes[i].getAttribute('id') == 'final')
     						{
                                resetChat();
                                bProc = false;
     						}
     						chat_div.innerHTML += '<b>' +user_node[0].firstChild.nodeValue + '</b>: ';
     						chat_div.innerHTML += text_node[0].firstChild.nodeValue + '<br />';
     						chat_div.scrollTop = chat_div.scrollHeight;
     						lastMessage = message_nodes[i].getAttribute('id');
     					}
			        }
 					mTimer = setTimeout('getChatText();',3000);
 				}
 			}

 			function blockSubmit()
 			{
 				sendChatText();
 			}

 			function resetChat()
 			{
 				if (sendReq.readyState == 4 || sendReq.readyState == 0)
 				{
 				    if (bIsPathTranslated)
 				    {
 				       sReqUrl = sHome + 'index.php/' + 'public/im/chat_'+iChat+'/last_' + lastMessage;
 				    }
 				    else
 				    {
 				        var sReqUrl = sHome + 'index.php?' + sGetPathVar + '=' + '/public/im/chat_'+iChat+'/last_' + lastMessage;
 				    }
 				    sendReq.open("POST", sReqUrl, true);
 					sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 					sendReq.onreadystatechange = handleResetChat;
 					var param = 'action=reset';
 					sendReq.send(param);
 					document.getElementById('maintext').value = '';
 				}
 			}

 			function handleResetChat()
 			{
 				document.getElementById('maintext').disabled = true;
 				document.getElementById('btn_send_chat').disabled = true;
 				receiveReq.abort();
 				sendReq.abort();
 			}

 			function entsub(event)
 			{
 				var Key = event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode);

 				if (Key == 13)
 				{
 					blockSubmit();
 					document.getElementById('maintext').value = '';
 				    document.getElementById('maintext').focus();
 				}
 				else
 				{
 			        return true;
 				}
 			}
 		</script>
 	{/literal}
<body>
<table style="width:100%;" cellpadding="0" cellspacing="5">
        <tr>
            <td style="width:75%;text-align:left;vertical-align:top;font-size:10pt;">
                <div style="padding:10px;">
                    <div id="div_chat" style="height: 300px; width: 500px; overflow: auto; background-color: #CCCCCC; border: 1px solid #555555;color:#000;"></div>
 		             <br />
 		            <div style="padding: 5px;">
		<a href="javascript:void(0);" onclick="insertAtCursor(document.getElementById('maintext'),':artist:',2);"><img src="design/pic/smile/artist.gif" alt="" /></a>
		<a	href="javascript:void(0);" onclick="insertAtCursor(document.getElementById('maintext'),':biggrin:',2);"><img src="design/pic/smile/biggrin.gif" alt="" /></a>
		<a href="javascript:void(0);" onclick="insertAtCursor(document.getElementById('maintext'),':bowl:',2);"><img src="design/pic/smile/bowl.gif" alt="" /></a>
		<a	href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':dizzy:',2);"><img src="design/pic/smile/dizzy.gif" alt="" /></a>
		<a	href="javascript:void(0);" onclick="insertAtCursor(document.getElementById('maintext'),':sad:',2);"><img src="design/pic/smile/sad.gif" alt="" /></a>
		<a	href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':shocked:',2);"><img src="design/pic/smile/shocked.gif" alt="" /></a>
		<a href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':smile:',2);"><img src="design/pic/smile/smile.gif" alt="" /></a>
		<a	href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':tongue:',2);"><img src="design/pic/smile/tongue.gif" alt="" /></a>
		<a	href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':wacko:',2);"><img src="design/pic/smile/wacko.gif" alt="" /></a>
		<a	href="javascript:void(0);"	onclick="insertAtCursor(document.getElementById('maintext'),':wink:',2);"><img src="design/pic/smile/wink.gif" alt="" /></a>
		<span	style="font-size: 7pt; vertical-align: top;">[
			<a	href="javascript:void(0);"	onclick="popUp2('{url link=public.popup.emoteicons noT=1}',400,400,'yes',400,100)">
				{language text="more_emoticons_403"}
			</a> ]
		</span>
	</div>
             		<form id="frmmain" name="frmmain" onsubmit="return blockSubmit();" style="margin:0px;">
             			<textarea cols="60" rows="6"  id="maintext" name="maintext" onkeyup="return (!entsub(event)) ? false : entsub(event);" style="vertical-align:middle;"></textarea>
             			<input type="button" name="btn_send_chat" id="btn_send_chat" value="send" onclick="javascript:sendChatText();" />
             		</form>
                </div>
            </td>
            <td style="width:25%;text-align:left;vertical-align:top;font-size:9pt;" class="color">
                <div style="padding:5px;">
                    <div style="padding:5px;" class="border13">
 	                    {$sUser1}
 	                    <div style="padding:5px;">
                            {Account::Avatar sUser=$sUser1 iSize=75 class="pic1" alt="" onmouseover="showInfo5('`$sUser1`', '', '');this.className='pic2';" onmouseout="this.className='pic1';return nd();"}
 	                    </div>
                    </div>
                    <br /><br />
                    <div style="padding:5px;" class="border13">
                 		{$sUser2}
                 		<div style="padding:5px;">
                            {Account::Avatar sUser=$sUser2 iSize=75 class="pic1" onmouseover="showInfo5('`$sUser2`', '', '');this.className='pic2';" onmouseout="this.className='pic1';return nd();"}
                        </div>
                    </div>
                </div>
            </td>
        </tr>
</table>
<div id="p_status" style="position:absolute; z-index:900;"></div>
</body>
<script language="javascript" type="text/javascript">setTimeout("startChat();", 500);</script>